package com.xinshujia.utils;

import com.alibaba.nacos.common.http.param.MediaType;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.xinshujia.utils.response.RespResult;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/**
 * @author: 野狼上校
 * @create: 2023-06-04  17:44
 * @version: 1.0
 * @description: HttpServletResponse工具类
 */
public class HttpServletResponseUtil {
    public void responseAuthenticationResult(HttpServletResponse response, RespResult result) throws IOException {
        response.setContentType(MediaType.APPLICATION_JSON);
        String json = new Gson().toJson(result);
        response.getWriter().println(json);
        response.getWriter().close();
    }
}
